/** @defgroup type Cargo type define
 * @{
 */
/*
 * Application\Inc\type.h
 *
 *
 *
 * Author: Chao-Chi Kuo <chaochi_kuo@systech.com.tw>
 * Copyright (c) 2010 SYSTEMS & TECHNOLOGY CORP. <http://www.systech.com.tw/>
 * All rights reserved.
 *
 * Modifications:
 * 2009/11/18 Chao-Chi Kuo	first implemetation
 *
 * $Id: type.h 196 2010-08-05 01:54:48Z chaochi_kuo $
 */


#ifndef __TYPE_H_
#define __TYPE_H_

#ifdef  __cplusplus
extern "C" {
#endif		/* __cplusplus */

/** @name ASCII Code define
 * @{
 */
#define ASC_BS		0x08		///< Backspace
#define ASC_CR		0x0D		///< \r
#define ASC_LF		0x0A		///< \n
#define ASC_SPACE	0x20
#define ASC_SUB		0x1A		///< Ctrl Z
/** @} */

/** @name Unit Conversion define
 * @{
 */
#define KNOT_2_KMH		1.852	///< 1 knot = 1.852 km/h
#define KNOT_2_MS		0.514	///< 1 knot = 0.514 m/s
/** @} */

#ifndef NULL
#define NULL ((void *)0)
#endif



#pragma pack(1)
/**
 * @union _var16
 * @brief union type for 16bit varable
 */
typedef union _var16{
	unsigned short u16;		///< 16bit variable
	short s16;
	struct {
		unsigned char lo;	///< 8bit low byte variable
		unsigned char hi;	///< 8bit high byte variable
	}u8;
}var16;

/**
 * @union _var32
 * @brief union type for 32bit variable
 */
typedef union _var32{
	unsigned long u32;		///< 32bit variable
	long s32;
	struct {
		unsigned short lo;	///< 16bit lower variable
		unsigned short hi;	///< 16bit higher variable
	}u16;
	struct {
		unsigned char b0;	///< 8bit byte 0 variable
		unsigned char b1;	///< 8bit byte 1 variable
		unsigned char b2;	///< 8bit byte 2 variable
		unsigned char b3;	///< 8bit byte 3 variable
	}u8;
}var32;

typedef union _var64 {
	unsigned long long u64;
	long long s64;
	struct {
		unsigned long lo;
		unsigned long hi;
	}u32;
	struct {
		unsigned short b0;
		unsigned short b1;
		unsigned short b2;
		unsigned short b3;
	}u16;
	struct {
		unsigned char b0;	///< 8bit byte 0 variable
		unsigned char b1;	///< 8bit byte 1 variable
		unsigned char b2;	///< 8bit byte 2 variable
		unsigned char b3;	///< 8bit byte 3 variable
		unsigned char b4;	///< 8bit byte 0 variable
		unsigned char b5;	///< 8bit byte 1 variable
		unsigned char b6;	///< 8bit byte 2 variable
		unsigned char b7;	///< 8bit byte 3 variable
	}u8;
}var64;

typedef struct _PARAMETER_DECODE {
	const char *code;
	int (*fun)(char *buf);
	const char *type_string;
	unsigned short offset;
}PARAMETER_DECODE;

//fenris 20101213 for GPS UBX Parameter decode table
typedef struct _UBX_PARAMETER_DECODE {
    const unsigned short id;
    int (*fun)(char *buf);
    unsigned short offset;
}UBX_PARAMETER_DECODE ;

typedef struct _DATE_TIME {
	unsigned char sec;
	unsigned char min;
	unsigned char hour;
	unsigned char day;
	unsigned char month;
	unsigned short year;
}DATE_TIME;


#ifdef __cplusplus
}
#endif	/* __cplusplus */
#endif	/* __TYPE_H_ */
/** @} */